package com.ruoyi.backstage.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.zzw.domain.CaseInfo;
import com.ruoyi.zzw.service.TCaseInfoService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 民转刑事案件管理Controller
 * 
 * @author ruoyi
 * @date 2023-12-06
 */
@RestController
@RequestMapping("/backstage/caseInfo")
public class BackCaseInfoController extends BaseController
{
    @Autowired
    private TCaseInfoService tCaseInfoService;

    /**
     * 查询民转刑事案件管理列表
     */
    @PreAuthorize("@ss.hasPermi('system:caseInfo:list')")
    @GetMapping("/list")
    public TableDataInfo list(CaseInfo caseInfo)
    {
        startPage();
        List<CaseInfo> list = tCaseInfoService.selectTCaseInfoList(caseInfo);
        return getDataTable(list);
    }

    /**
     * 导出民转刑事案件管理列表
     */
    @PreAuthorize("@ss.hasPermi('system:caseInfo:export')")
    @Log(title = "民转刑事案件管理", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, CaseInfo caseInfo)
    {
        List<CaseInfo> list = tCaseInfoService.selectTCaseInfoList(caseInfo);
        ExcelUtil<CaseInfo> util = new ExcelUtil<CaseInfo>(CaseInfo.class);
        util.exportExcel(response, list, "民转刑事案件管理数据");
    }

    /**
     * 获取民转刑事案件管理详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:caseInfo:query')")
    @GetMapping(value = "/{cCaseId}")
    public AjaxResult getInfo(@PathVariable("cCaseId") Long cCaseId)
    {
        return success(tCaseInfoService.selectTCaseInfoByCCaseId(cCaseId));
    }

    /**
     * 新增民转刑事案件管理
     */
    @PreAuthorize("@ss.hasPermi('system:caseInfo:add')")
    @Log(title = "民转刑事案件管理", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody CaseInfo caseInfo)
    {
        return toAjax(tCaseInfoService.insertTCaseInfo(caseInfo));
    }

    /**
     * 修改民转刑事案件管理
     */
    @PreAuthorize("@ss.hasPermi('system:caseInfo:edit')")
    @Log(title = "民转刑事案件管理", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody CaseInfo caseInfo)
    {
        return toAjax(tCaseInfoService.updateTCaseInfo(caseInfo));
    }

    /**
     * 删除民转刑事案件管理
     */
    @PreAuthorize("@ss.hasPermi('system:caseInfo:remove')")
    @Log(title = "民转刑事案件管理", businessType = BusinessType.DELETE)
	@DeleteMapping("/{cCaseIds}")
    public AjaxResult remove(@PathVariable Long[] cCaseIds)
    {
        return toAjax(tCaseInfoService.deleteTCaseInfoByCCaseIds(cCaseIds));
    }
}
